package com.sofwin.controller;

import com.github.pagehelper.PageInfo;
import com.sofwin.dto.CCompanyDto;
import com.sofwin.pojo.CCompany;
import com.sofwin.service.CCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: ssm-parent
 * @description: 企业注册审核
 * @author: Mr.lzk
 * @create: 2021-04-25 11:37
 * @Version 1.0
 **/
@RequestMapping("registercode")
@Controller
public class RegisterCodeController {
    @Autowired
    private CCompanyService cCompanyService;
    /**
     * @Description: 分页查询所有待审核信息
     * @Author: Mr.lzk
     * @Date: 2021/4/26 15:06
     * @Param: * @param company:
     * @param pageNumber:
     * @param pageSize:
     * @param model:
     * @Return: * @return: java.lang.String
     **/
    @RequestMapping("data")
    public String toRegisterCode(CCompany company, @RequestParam(required = true,defaultValue = "1") Integer pageNumber, @RequestParam(required = true,defaultValue = "5") Integer pageSize, Model model){
        PageInfo<CCompanyDto> companyPageInfo = cCompanyService.selectCompanyListByPage(company,pageNumber,pageSize);
        model.addAttribute("data",companyPageInfo.getList());
        model.addAttribute("page",companyPageInfo);
        model.addAttribute("company",company);
        return "register/registercode";
    }
    /**
     * @Description: 通过审核
     * @Author: Mr.lzk
     * @Date: 2021/4/26 15:06
     * @Param: * @param id:
     * @Return: * @return: java.util.Map
     **/
    @RequestMapping("pass")
    @ResponseBody
    public Map pass(Integer id){
        boolean status = cCompanyService.pass(id);
        Map map = new HashMap();
        map.put("status",status);
        return map;
    }

    /**
     * @Description: 未通过审核
     * @Author: Mr.lzk
     * @Date: 2021/4/26 15:09
     * @Param: * @param id:
     * @Return: * @return: java.util.Map
     **/
    @RequestMapping("noPass")
    @ResponseBody
    public Map noPass(Integer id){
        boolean status = cCompanyService.noPass(id);
        Map map = new HashMap();
        map.put("status",status);
        return map;
    }

}
